using System;
using UnityEngine;

namespace Voodoo.Sauce.Internal
{
	public static class VoodooLog
	{
		private static VoodooLogLevel _logLevel;

		private const string TAG = "VoodooSauce";

		public static void SetLogLevel(VoodooLogLevel level)
		{
			_logLevel = level;
		}

		public static void Log(string tag, string message)
		{
			if (!Application.isEditor || _logLevel >= VoodooLogLevel.DEBUG)
			{
				UnityEngine.Debug.Log(Format(tag, message));
			}
		}

		public static void LogE(string tag, string message)
		{
			if (!Application.isEditor || _logLevel >= VoodooLogLevel.ERROR)
			{
				UnityEngine.Debug.LogError(Format(tag, message));
			}
		}

		public static void LogW(string tag, string message)
		{
			if (!Application.isEditor || _logLevel >= VoodooLogLevel.WARNING)
			{
				UnityEngine.Debug.LogWarning(Format(tag, message));
			}
		}

		private static string Format(string tag, string message)
		{
			return string.Format("{0} - {1}/{2}: {3}", DateTime.Now, "VoodooSauce", tag, message);
		}
	}
}
